﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using WCFThree.Entity;
using WCFThree.Abstract;
using WCFThree.Proxy;

namespace WCFThree.Test
{
    class Program
    {
        static void Main(string[] args)
        {
            Test_Student();

            Console.Read();
        }

        static void Test_Student()
        {

            RemoteServiceFactory _remote = new RemoteServiceFactory();
            IStudent _IStudent = _remote.GetStudent();

            ////1.添加学生
            //WCFThree.Entity.student stu1 = new Entity.student()
            //{
            //    sno = "110",
            //    sname = "李四",
            //    ssex = "男",
            //    sbirthday = DateTime.Now,
            //    _class = "95033"
            //};
            //_IStudent.Add(stu1);

            ////2.获取列表
            //List<WCFThree.Entity.student> stuList = _IStudent.GetList();
            //foreach (var item in stuList)
            //{
            //    //编号-姓名---学习的课程数量(获取关联表数据失效)
            //    Console.WriteLine(string.Format("{0}-{1}--{2}", item.sno, item.sname, item.scores.Count));
            //}


            //3.获取指定对象及关联数据----方式1：独立请求
            //WCFThree.Entity.student stu2 = _IStudent.GetModel("101");
            //Console.WriteLine(stu2.sname);
            //IScore _IScore = _remote.GetScore();
            //List<WCFThree.Entity.score> scoreList = _IScore.GetList_Stu(stu2.sno);
            //foreach (var item in scoreList)
            //{
            //    Console.WriteLine(string.Format("{0}-{1}", item.sno, item.degree));
            //}

            //获取关联表数据方式2
            WCFThree.Entity.student stu3 = _IStudent.GetModel_Related("101");
            Console.WriteLine(stu3.sname);
            Console.WriteLine(stu3.scores.Count);
            Console.WriteLine(stu3.scores.First().degree);
        }
    }
}
